home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
et
/
src
/
gaiji.c
< prev
next >
Wrap
Text File
|
1993-07-08
|
2KB
|
75 lines
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
void set_s(int n, char *s_p);
char nl_a[] = {0x0d, 0x0a, '\0'};
void main()/*gaiji*/
{
FILE *File, *Temp;
int i, j;
unsigned char n, u_a[16], v_a[16];
char c_a[200], s_a[200];
File = fopen("et.dot", "rb");
Temp = fopen("etg.h", "wb");
fseek(File, 16L, 0);
fread(&n, 1, 1, File);
fseek(File, 50L, 0);
for (j = 0; n; ) {
i = fgetc(File);
if (j % 2)
u_a[j/2] = i;
else
v_a[j/2] = i;
j++;
if (!(j % 32)) {
j = 0;
for (i = 0; i < 16; i++) {
if (!(i%8))
strcpy(s_a, "\t");
set_s(v_a[i], c_a);
strcat(c_a, ", ");
strcat(s_a, c_a);
if (!((i+1)%8)) {
strcat(s_a, nl_a);
fwrite(s_a, sizeof(char), strlen(s_a), Temp);
}
}
for (i = 0; i < 16; i++) {
if (!(i%8))
strcpy(s_a, "\t");
set_s(u_a[i], c_a);
strcat(c_a, ", ");
strcat(s_a, c_a);
if (!((i+1)%8)) {
strcat(s_a, nl_a);
fwrite(s_a, sizeof(char), strlen(s_a), Temp);
}
}
fseek(File, 2L, 1);
n--;
}
}
fclose(File);
fclose(Temp);
}
void set_s(int n, char *s_p)/*gaiji*/
{
int i, j;
char buf_a[10];
i = 0;
do {
j = n % 10;
j += '0';
buf_a[i++] = j;
n /= 10;
} while (n);
for (i; i; i--)
*s_p++ = buf_a[i-1];
*s_p = '\0';
}